package cn.patient.pp.module.fiveInOne.dal.mysql;

import java.util.*;

import cn.patient.pp.framework.common.pojo.PageResult;
import cn.patient.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.patient.pp.framework.mybatis.core.mapper.BaseMapperX;

import cn.patient.pp.module.fiveInOne.dal.dataobject.KeyPersonProtectionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.patient.pp.module.fiveInOne.controller.admin.vo.*;

/**
 * 重点人员包保信息 Mapper
 *
 * @author 驻马店超管
 */
@Mapper
public interface KeyPersonProtectionMapper extends BaseMapperX<KeyPersonProtectionDO> {

    default PageResult<KeyPersonProtectionDO> selectPage(KeyPersonProtectionPageReqVO reqVO, List<Long> loginUserDeptIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyPersonProtectionDO>()
                .eqIfPresent(KeyPersonProtectionDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(KeyPersonProtectionDO::getPatientName, reqVO.getPatientName())
                .eqIfPresent(KeyPersonProtectionDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(KeyPersonProtectionDO::getGender, reqVO.getGender())
                .betweenIfPresent(KeyPersonProtectionDO::getBirthDate, reqVO.getBirthDate())
                .eqIfPresent(KeyPersonProtectionDO::getPhone, reqVO.getPhone())
                .likeIfPresent(KeyPersonProtectionDO::getCurrentAddress, reqVO.getCurrentAddress())
                .eqIfPresent(KeyPersonProtectionDO::getGuardian, reqVO.getGuardian())
                .eqIfPresent(KeyPersonProtectionDO::getContact, reqVO.getContact())
                .eqIfPresent(KeyPersonProtectionDO::getGuardianPatientRelationship, reqVO.getGuardianPatientRelationship())
                .likeIfPresent(KeyPersonProtectionDO::getTownCadreName, reqVO.getTownCadreName())
                .eqIfPresent(KeyPersonProtectionDO::getTownCadrePhone, reqVO.getTownCadrePhone())
                .likeIfPresent(KeyPersonProtectionDO::getVillageCadreName, reqVO.getVillageCadreName())
                .eqIfPresent(KeyPersonProtectionDO::getVillageCadrePhone, reqVO.getVillageCadrePhone())
                .likeIfPresent(KeyPersonProtectionDO::getPoliceName, reqVO.getPoliceName())
                .likeIfPresent(KeyPersonProtectionDO::getDoctorName, reqVO.getDoctorName())
                .eqIfPresent(KeyPersonProtectionDO::getPolicePhone, reqVO.getPolicePhone())
                .eqIfPresent(KeyPersonProtectionDO::getDoctorPhone, reqVO.getDoctorPhone())
                .eqIfPresent(KeyPersonProtectionDO::getRiskAssessment, reqVO.getRiskAssessment())
                .eqIfPresent(KeyPersonProtectionDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(KeyPersonProtectionDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(KeyPersonProtectionDO::getDeptId, loginUserDeptIds)
                .orderByDesc(KeyPersonProtectionDO::getId));
    }

    KeyPersonProtectionRespVO selectDetailById(Integer id);

    // 批量插入
    void insertOrUpdate(List<KeyPersonProtectionImportExcelVO> batch);

}

